<?php
/**
 * Created by PhpStorm.
 * User: Sky
 * Date: 16/1/26
 * Time: 下午8:27
 */

use yii\helpers\Url;

$web = Url::to("@web");
?>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>地址管理</title>
    <script src="<?=$web?>/js/jquery.js"></script>
    <script src="<?=$web?>/js/tools.js"></script>
    <link href="<?=$web?>/css/public.css" rel="stylesheet" type="text/css">
    <link href="<?=$web?>/css/wx-home/address-management.css" rel="stylesheet" type="text/css">
    <script>

        $(function ($) {
            var w = $(document).width();
            if (w > 640) {
                w = 640;
            }
            $("html").css("font-size", w * 20 / 320);
        });
        $(document).ready(function () {
            if ($(".main").height() < $(window).height()) {
                $(".main").height($(window).height())
            }
        });

        edit_address=function(aid){
            window.location.href=addUrlPara('<?=Url::to(['wx-home/address-edit','backurl'=>$backurl]);?>','aid',aid);
        };
        del_address=function(aid){
            if(confirm('是否删除此地址?')){
                var data = {};
                data.id = aid;
                var re = requestJson("<?=Url::to(["wx-home/del-address-handle"])?>", data);
                if (re.status == 0) {
                    window.location.reload();
                } else {
                    alert(re.message);
                }
            }
        };
        set_address_default=function(aid){
                var data = {};
                data.id = aid;
                var re = requestJson("<?=Url::to(["wx-home/set-address-default-handle"])?>", data);
                if (re.status == 0) {
                    window.location.reload();
                } else {
                    alert(re.message);
                }
        };
        href_back=function(aid){
            var backurl='<?=$backurl;?>';
            if(backurl==''){
                alert(aid);
                return;
            }
            window.location.href=addUrlPara(backurl,'address_id',aid);
        };
    </script>
</head>
<body>

<div class="main">
    <?php
        foreach($addressList as $address){
     ?>
            <div class="address">
                <div class="address-head" onclick="href_back('<?=$address['ID']?>');">
                    <div class="address-headTop">
                        <div class="address-headTop-right"><?=$address['NAME']?></div>
                        <div class="address-headTop-left"><?=$address['PHONE']?></div>
                    </div>
                    <div class="address-headBottom"><?=$address['PROVINCE']?><?=$address['CITY']?><?=$address['REGION']?><?=$address['ADDRESS']?></div>
                </div>
                <div class="address-foot">
                    <div class="address-foot-checkbox">
                        <?php
                            if($address['IS_DEFAULT']=='1'){
                                ?>
                                <input class="choice-checkbox"  type="radio" name="c1" checked="checked">
                                <?php
                            }else{
                                ?>
                                <input class="choice-checkbox" type="radio" name="c1" onclick="set_address_default('<?=$address['ID']?>')">
                                <?php
                            }
                        ?>

                    </div>
                    <div class="address-foot-words">
                        默认地址
                    </div>
                    <div class="address-foot-btn" onclick="edit_address('<?=$address['ID']?>');">编辑</div>
                    <div class="address-foot-btn" onclick="del_address('<?=$address['ID']?>')">删除</div>
                </div>
            </div>

     <?php
        }
    ?>

    <!--<div class="address">
        <div class="address-head">
            <div class="address-headTop">
                <div class="address-headTop-right">曾福杰</div>
                <div class="address-headTop-left">15730096830</div>
            </div>
            <div class="address-headBottom">xxxxxxxxxxxxxxxxx</div>
        </div>
        <div class="address-foot">
            <div class="address-foot-checkbox">
                <input class="choice-checkbox" type="checkbox">
            </div>
            <div class="address-foot-words">
                设为默认地址
            </div>
            <div class="address-foot-btn">编辑</div>
            <div class="address-foot-btn">删除</div>
        </div>
    </div>-->
    <div class="foot-btn" onclick="edit_address('');">新增收货地址</div>
</div>
</body>
</html>